//
//  XSHJX.m
//  WeddingCar
//
//  Created by admin on 2017/3/3.
//  Copyright © 2017年 Sugar. All rights reserved.
//

#import "XSHJX.h"

@implementation XSHJX




+ (void)XSHJXErrer:(NSError *)error{
    
    [XBProgressHUD showProgressHUDWithText:error.localizedDescription];
}
+ (void)XSHJXResult:(id)result finishBlock:(void(^)())finishBlock{

    [self XSHJXResult:result loadingView:nil finishBlock:finishBlock errorBlock:nil];


}
+ (void)XSHJXResult:(id)result loadingView:(UIView *)loadingView finishBlock:(void(^)())finishBlock{
    
    [self XSHJXResult:result loadingView:loadingView finishBlock:finishBlock errorBlock:nil];

}

+ (void)XSHJXResult:(id)result loadingView:(UIView *)loadingView finishBlock:(void(^)())finishBlock  errorBlock:(void(^)())errorBlock{


    if(result){
        
        if ([result[@"status"] integerValue] == 1) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                
                finishBlock();
                
            });
            
        }else if ([result[@"status"] integerValue] == -1) {
            
            [self errorLoadingWithView:loadingView];
            [XBProgressHUD showProgressHUDWithText:@"账号被抢登"];
            
            kGCDGlobal(^{
                
                [[NSNotificationCenter defaultCenter] postNotificationName:Login_UserRob_Notification object:nil];
            });
            
            
        }else if([result[@"status"] integerValue] == -2) {
            
            ///特别点 进入预约服务
            dispatch_async(dispatch_get_main_queue(), ^{
                
                
                finishBlock();
                
            });
            
        }else{
            
            [self errorLoadingWithView:loadingView];
            [XBProgressHUD showProgressHUDWithText:result[@"info"]];
            
            ///错误返回
            if(errorBlock){
                
                dispatch_async(dispatch_get_main_queue(), ^{
                    
                    
                    errorBlock();
                    
                });
                
            }
            
        }
        
    }else{
        
        [self errorLoadingWithView:loadingView];
        [XBProgressHUD showProgressHUDWithText:@"没有数据"];
        
        
    }


}

+ (void)errorLoadingWithView:(UIView *)loadingView{
    
    if(loadingView){
        
    
        [loadingView errorLoadingWithTitle:nil];
    
    }
    
}

@end
